package com.springboot.framework.mvc.service;

import com.springboot.framework.mvc.mapper.BaseMapper;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.Map;

/**
 * 定义公用方法的的实现类,业务层只需继承就可以调用
 * @param <T> 实体类泛型
 * @param <M> Mapper泛型
 */
public abstract class BaseServiceImpl<T,M extends BaseMapper<T>> implements BaseService<T> {

    @Autowired
    private M m;

    @Override
    public List<T> getByCondition(T model){
        return m.getByCondition(model);
    }

    @Override
    public List<T> getByCondition(Map model){
        return m.getByCondition(model);
    }

    @Override
    public T getById(int id){
        return m.getById(id);
    }

    @Override
    public Long insert(T model){
        return m.insert(model);
    }

    @Override
    public Long updateById(T model){
        return m.updateById(model);
    }

    @Override
    public Long deleteById(int id){
        return m.deleteById(id);
    }

    @Override
    public Boolean existById(int id){
        return m.existById(id);
    }

}
